package com.wm.blog_admin.controller.base;

import com.wm.blog_common.constatnt.CommonConstant;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.http.HttpServletRequest;

/***
 * @ClassName: AdminBaseController
 * @Description: admin后台controller基类
 * @Author: wm_yu
 * @Create_time: 22:46 2020-3-24
 */

public class AdminBaseController {

    /**
     * 当前登录人的id
     * @param request
     * @return
     */
    public Long currentAdminId(HttpServletRequest request){
        String header = request.getHeader(CommonConstant.AMIND_ID);
        return StringUtils.isNotEmpty(header) ? Long.parseLong(header) : -1L;
    }

    /**
     * 当前的请求头
     * @param request
     * @return
     */
    public String currentAuthorization(HttpServletRequest request){
       return request.getHeader(CommonConstant.AMIND_Authorization);
    }
}
